<template>
	<div>
		<HomeHeader></HomeHeader>
		<HomeLeft :cur="3"></HomeLeft>
		<div id="main">
			<div id="web_con">
				<div class="web_wp">
					<div class="web_location">
						<div class="here_area">
							<strong>当前位置：</strong>财富管理
						</div>
						<div class="here_btn">
							<span style="font-size: 14px;display: block;margin-top: 8px;">会员存入金额总计：<b style="font-size: 20px;color: rgb(23, 114, 246);">{{threeinfo/10000}}万</b></span>
						</div>
					</div>
					<div class="filter clearfix">
						<div class="aa">
							<div class="item">
								<span>类别 :</span>
								<select class="select" v-model="type">
									<option value="all">全部</option>
									<option value="30">进行中（全部）</option>
									<option value="31">进行中（到期续签）</option>
									<option value="32">进行中（到期赎回）</option>
									<option value="10">线下待支付（支付失败）</option>
									<option value="20">待确认</option>
									<option value="40">已赎回</option>
								</select>
							</div>
							<div class="item">
								<span>开始时间：</span>
								<el-date-picker v-model="start_time" type="date" placeholder="开始时间" value-format="yyyy-MM-dd">
								</el-date-picker>
							</div>
							
							<div class="item">
								<span>结束时间：</span>
								<el-date-picker v-model="end_time" type="date" placeholder="结束时间" value-format="yyyy-MM-dd">
								</el-date-picker>
							</div>
							
							
							<div class="item">
								<span>关键词：</span>
								<input type="text" v-model="keywords" placeholder="请输入" class="fill_text">
							</div>
							
							<div class="item">
								<button class="but_search" @click="Seach()">搜 索</button>
							</div>
						</div>
						<div class="bb">
							
							<a href="javascript:;" class="web_btn btn_refresh" @click="ExportList()"><em
									class="iconfont icon-shdcexcel"></em>导出</a>

							<!-- <navigator url="/pages/shop/edit" hover-class="none" class="web_btn">
							
								<em class="iconfont icon-shdcsub-add"></em>添加
							</navigator>
							<a href="javascript:;" class="web_btn" @click="DeleteList()">
								<em class="iconfont icon-shdcsub-add-copy"></em>删除
							</a> -->
							<a href="javascript:;" class="web_btn btn_refresh" @click="Refresh()"><em
									class="iconfont icon-shdcshuaxin"></em>刷新</a>
						</div>
					</div>

					<div class="web_table">
						<table>
							<tr>
								<!-- <th class="tac" style="width: 60px;">选择</th> -->
								<th class="tac">交易编号</th>
								<th class="tac">用户名称</th>
								<th class="tac">商户号</th>
								<th class="tac">存入金额</th>
								<th class="tac">支付方式</th>
								<th class="tac">年化收益率</th>
								<th class="tac">预计收益</th>
								<th class="tac">赠送积分</th>
								<th class="tac">生效日期</th>
								<th class="tac">到期日期</th>
								<th class="tac">状态</th>
								<th class="tac">操作</th>
								<th class="tac">详情</th>
							</tr>
							<tr v-for="(item,i) in listinfo.data" :key="i">
								<!-- <td class="tac">
									<el-checkbox></el-checkbox>
								</td> -->
								<td class="tac">{{item.payno}}</td>
								<td class="tac">
									<span v-if="item.user">{{item.user.nickname}}</span>
								
								</td>
								<td class="tac">
									<span v-if="item.user">{{item.user.merchantno}}</span>
								</td>
								<td class="tac">{{item.pay_fee}}</td>
								<td class="tac">
									<span v-if="item.pay_type=='offline'">线下支付</span>
									<span v-else-if="item.pay_type=='wechat'">微信支付</span>
									<span v-else>{{item.pay_type}}</span>
								</td>
								<td class="tac">
									<span>{{item.current.balance/item.pay_fee*100}}%</span>
								</td>
								<td class="tac">
									<span v-if="item.current">{{item.current.balance}}</span>
									<span v-else>-</span>
								</td>
								<td class="tac">{{item.current.integral}}</td>
								<td class="tac">
									<span v-if="item.status==30">{{item.current.start_at}}</span>
									<span v-else>---</span>
								</td>
								<td class="tac">
									<span v-if="item.status==30">{{item.current.end_at}}</span>
									<span v-else>---</span>
								</td>
								<td class="tac">
									<span v-if="item.status==10&&item.pay_type=='offline'">线下待付款</span>
									<span v-if="item.status==10&&item.pay_type=='wechat'">支付失败</span>
									<span v-if="item.status==20&&item.pay_type=='offline'">待确认</span>
									<span
										v-if="item.status==30">进行中（{{item.current.action=='renew'?'到期续签':'到期赎回'}}）</span>
								</td>

								<td class="tac">
									<navigator v-if="item.status==20&&item.pay_type=='offline'"
										:url="'/pages/wealth/confirm?id=' + item.id" hover-class="none">
										<el-button type="primary" size="mini">去确认</el-button>
									</navigator>
									
									<navigator v-else-if="item.history>1" :url="'/pages/wealth/history?id=' + 1" hover-class="none">
										<el-button type="info" size="mini">查看历史</el-button>
									</navigator>
									
									<span v-else>-</span>
								</td>
								<td class="tac">
									<navigator :url="'/pages/wealth/edit?id=' + item.id" hover-class="none"
										class="editBtn" title="编辑">
									</navigator>
								</td>
							</tr>
							<!-- <tr>
								<td class="tac">
									<el-checkbox></el-checkbox>
								</td>
								<td class="tac">123456123456</td>
								<td class="tac">张三</td>
								<td class="tac">2000</td>
								<td class="tac">3%</td>
								<td class="tac">60</td>
								<td class="tac">2000</td>
								<td class="tac">---</td>
								<td class="tac">---</td>
								<td class="tac">待确认</td>
								<td class="tac">

									<navigator :url="'/pages/wealth/confirm?id=' + 1" hover-class="none">
										<el-button type="primary" size="mini">去确认</el-button>
									</navigator>
								</td>
								<td class="tac">
									<navigator :url="'/pages/wealth/edit?id=' + 1" hover-class="none" class="editBtn"
										title="编辑">
									</navigator>
								</td>
							</tr>
							<tr>
								<td class="tac">
									<el-checkbox></el-checkbox>
								</td>
								<td class="tac">123456123456</td>
								<td class="tac">张三</td>
								<td class="tac">2000</td>
								<td class="tac">3%</td>
								<td class="tac">60</td>
								<td class="tac">2000</td>
								<td class="tac">2024-05-27</td>
								<td class="tac">2025-05-27</td>
								<td class="tac">进行中（到期续签）</td>
								<td class="tac">

									-
								</td>
								<td class="tac">
									<navigator :url="'/pages/wealth/edit?id=' + 1" hover-class="none" class="editBtn"
										title="编辑">
									</navigator>
								</td>
							</tr>
							<tr>
								<td class="tac">
									<el-checkbox></el-checkbox>
								</td>
								<td class="tac">123456123456</td>
								<td class="tac">张三</td>
								<td class="tac">2000</td>
								<td class="tac">3%</td>
								<td class="tac">60</td>
								<td class="tac">2000</td>
								<td class="tac">2024-05-27</td>
								<td class="tac">2025-05-27</td>
								<td class="tac">进行中（到期赎回）</td>
								<td class="tac">
									<navigator :url="'/pages/wealth/history?id=' + 1" hover-class="none">
										<el-button type="info" size="mini">查看历史</el-button>
									</navigator>
								</td>

								<td class="tac">
									<navigator :url="'/pages/wealth/edit?id=' + 1" hover-class="none" class="editBtn"
										title="编辑">
									</navigator>
								</td>
							</tr>
							<tr>
								<td class="tac">
									<el-checkbox></el-checkbox>
								</td>
								<td class="tac">123456123456</td>
								<td class="tac">张三</td>
								<td class="tac">2000</td>
								<td class="tac">3%</td>
								<td class="tac">60</td>
								<td class="tac">2000</td>
								<td class="tac">2024-05-27</td>
								<td class="tac">2025-05-27</td>
								<td class="tac">已赎回</td>
								<td class="tac">

									-
								</td>
								<td class="tac">
									<navigator :url="'/pages/wealth/edit?id=' + 1" hover-class="none" class="editBtn"
										title="编辑">
									</navigator>
								</td>
							</tr> -->
						</table>
					</div>
					<div class="web_page">
						<el-pagination background @current-change="ChengPage" :current-page="page" :page-size="10"
							layout="total,prev, pager,next" :total="listinfo.total">
						</el-pagination>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import HomeHeader from '../components/Header.vue'
	import HomeLeft from '../components/Left.vue'
	export default {
		components: {
			HomeHeader,
			HomeLeft,
		},
		data() {
			return {
				page: 1,
				listinfo: [],
				keywords: '',
				type: 'all',
				start_time:'',
				end_time:'',
				threeinfo:{},
			}
		},
		
		onShow() {
			let that = this;
			let params = this.$route.query;
			if (params.time == 0) {
				that.start_time = that.common.GetNowTime();
				that.end_time = that.common.GetNowTime();
			} else if (params.time == 1) {
				var _tiem = that.common.GetNowTime();
				that.start_time = _tiem.slice(0, 8) + "01";
				that.end_time = that.common.GetNowTime();
			}			
			this.GetList();
		},
		methods: {	
			
			
			//导出
			ExportList:function(){
				let that = this;
				let _data = {
					status: that.type > 30 && that.type < 40 ? '30' : that.type,
					keywords: that.keywords,
					range:[],
					export:'order'
				};
				if(that.start_time){
					_data.range[0] = that.start_time;
					_data.range[1] = that.end_time?that.end_time:that.start_time
				}
				else if(that.end_time){
					_data.range[0] = that.start_time?that.start_time:that.end_time
					_data.range[1] = that.end_time
				}
				
				var _url = 'http://bylm.zxinvest.cn/api/admin/pay?export=order&keywords=' + that.keywords + '&range=' +_data.range + '&status=' + _data.status +  '&token=' + that.common.GetStorage('bytoken');			
				
				
				// 创建一个隐藏的<iframe>元素
				const iframe = document.createElement('iframe');
				iframe.style.display = 'none';				
				// 设置<iframe>的src为接口地址
				iframe.src = _url;				
				// 将<iframe>添加到文档中
				document.body.appendChild(iframe);	
					
					
				// window.open(_url, '_blank');
			},
			
			

			Refresh: function() {
				this.keywords = '';
				this.start_time = '';
				this.end_time = '';
				this.Seach();
			},

			Seach: function() {
				this.page = 1;
				this.GetList();
			},


			GetList: function() {
				let that = this;
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				var _data = {
					status: that.type > 30 && that.type < 40 ? '30' : that.type,
					keywords: that.keywords,
					page: that.page,
					per_page: 10,
					range:[],
				};
				
				if(that.start_time){
					_data.range[0] = that.start_time;
					_data.range[1] = that.end_time?that.end_time:that.start_time
				}
				else if(that.end_time){
					_data.range[0] = that.start_time?that.start_time:that.end_time
					_data.range[1] = end_time
				}	
				if (that.type == 31) {
					_data.action = 'renew'
				}
				if (that.type == 32) {
					_data.action = 'redeem'
				}
				that.common.http('GET', 'pay', _data, function(res) {
					uni.hideLoading();
					console.log(res.data)
					that.listinfo = res.data
					that.threeinfo = res.data.totalData.payFee
				});
			},
			LookTest: function(id) {
				uni.navigateTo({
					url: '/pages/member/info?id=' + id
				})
			},
			
			ChengPage:function(e){
				this.page = e;
				this.GetList();
			}
		}
	}
</script>

<style>


</style>